﻿using System.Net;

namespace ThresholdAssistant.Tools.Extensions
{
    /// <summary>
    /// IP拓展类
    /// </summary>
    public static class IPAddressExtensions
    {
        /// <summary>
        /// 格式化IP地址
        /// </summary>
        /// <param name="ipAddress">传进来的IP地址</param>
        /// <returns></returns>
        public static string FormatIP(this string ipAddress)
        {
            if (!string.IsNullOrWhiteSpace(ipAddress))
            {
                return IPAddress.TryParse(ipAddress, out IPAddress formatIpAddress) ? formatIpAddress.ToString() : string.Empty;
            }
            return string.Empty;
        }
    }
}